//
//  STDSAttribFill.cpp
//  STDSRenderSDKIOS
//
//  Created by 陈学明 on 2023/3/27.
//

#include "STDSAttribFill.hpp"

STDSAttribFill::STDSAttribFill() {
    mCountParticle = 1;
    mCountVertices = 1;
    _reset();
}

void STDSAttribFill::draw(vector<int> &vecCount, vector<float> _arr) {
    if (vecCount.empty() || 0 == _arr.size())
        return;

    glBindBuffer(GL_ARRAY_BUFFER, 0);

    glVertexAttribPointer((GLuint) mPosVex, 3, GL_FLOAT, GL_FALSE, 0, _arr.data());
    glEnableVertexAttribArray((GLuint) mPosVex);

    int off = 0;
    int count = 0;
    for (int i = 0; i < vecCount.size(); ++i) {
        count = vecCount[i];
        mDrawFunc(mArrIdx, count, off);
        off += count;
    }

    glBindBuffer(GL_ARRAY_BUFFER, 0);
}

void STDSAttribFill::_resetDrawFunc() {
    mDrawFunc = STDSGLFunctions::draw_ARR_TRIFAN;
}
